}
}
+function newWS(loc) {
+ var ws = null;
+ if ("WebSocket" in window) {
+ ws = new WebSocket(loc, "broadway");
+ } else if ("MozWebSocket" in window) { // Firefox 6
+ ws = new MozWebSocket(loc);
+ } else {
+ alert("WebSocket not supported, broadway will not work!");
+ }
+ return ws;
+}
+
function connect()
{
var url = window.location.toString();
var loc = window.location.toString().replace("http:", "ws:");
loc = loc.substr(0, loc.lastIndexOf('/')) + "/socket";
- var ws = null;
- if ("WebSocket" in window) {
- ws = new WebSocket(loc, "broadway");
- } else if ("MozWebSocket" in window) { // Firefox 6
- ws = new MozWebSocket(loc);
+ var supports_binary = newWS (loc + "-test").binaryType == "blob";
+ if (supports_binary) {
+ ws = newWS (loc + "-bin");
+ ws.binaryType = "arraybuffer";
} else {
- alert("WebSocket not supported, input will not work!");
- return;
+ ws = newWS (loc);
}
ws.onopen = function() {
gboolean seen_time;
gint64 time_base;
gboolean proto_v7_plus;
+ gboolean binary;
};
static void
}
static void
-start_input (HttpRequest *request)
+start_input (HttpRequest *request, gboolean binary)
{
char **lines;
char *p;
input->display = request->display;
input->connection = g_object_ref (request->connection);
input->proto_v7_plus = proto_v7_plus;
+ input->binary = binary;
data_buffer = g_buffered_input_stream_peek_buffer (G_BUFFERED_INPUT_STREAM (request->data), &data_buffer_size);
input->buffer = g_byte_array_sized_new (data_buffer_size);
else if (strcmp (escaped, "/broadway.js") == 0)
send_data (request, "text/javascript", broadway_js, G_N_ELEMENTS(broadway_js) - 1);
else if (strcmp (escaped, "/socket") == 0)
- start_input (request);
+ start_input (request, FALSE);
+ else if (strcmp (escaped, "/socket-bin") == 0)
+ start_input (request, TRUE);
else
send_error (request, 404, "File not found");